package com.ztk.threadpool;

import org.apache.tomcat.util.threads.ThreadPoolExecutor;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

public class ThreadPoolUtil {
    private static int THREAD_P00L_SIZE_10 = 10;
    private static int THREAD_P00L_SIZE_100 = 100;
    private static BlockingQueue<Runnable> queue10 = new LinkedBlockingQueue<>(THREAD_P00L_SIZE_10);
    private static BlockingQueue<Runnable> queue100 = new LinkedBlockingQueue<>(THREAD_P00L_SIZE_100);

    private static ThreadPoolExecutor threadPool10 = new ThreadPoolExecutor(2, THREAD_P00L_SIZE_10, 0, TimeUnit.SECONDS, queue10, new ThreadPoolExecutor.AbortPolicy());
    private static ThreadPoolExecutor threadPool100 =  new ThreadPoolExecutor(10, THREAD_P00L_SIZE_100, 0, TimeUnit.SECONDS, queue100, new ThreadPoolExecutor.AbortPolicy());

    public static ThreadPoolExecutor threadPoolExecutor10() {
        return threadPool10;
    }

    public static ThreadPoolExecutor threadPoolExecutor100() {
        return threadPool100;
    }
}
